﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;

namespace update_DataAdapter
{
    class Program
    {
        static void Main(string[] args)
        {
            SqlConnection conn =new SqlConnection();
            conn.ConnectionString = "Data Source=(local);Initial Catalog=sale;User Id=sa;Password=sa";
            SqlDataAdapter da = new SqlDataAdapter();
            SqlCommand secmd = new SqlCommand("select* from customers", conn);
            SqlCommand upcmd = new SqlCommand("update customers set Name=@name Where id=@id", conn);
            upcmd.Parameters.Add("@id",SqlDbType.Int,4,"id");
            upcmd.Parameters.Add("@name", SqlDbType.NVarChar, 30, "name");
            da.SelectCommand = secmd;
            da.UpdateCommand = upcmd;
            DataSet ds = new DataSet();
            da.Fill(ds, "customers");
            DataTable dt = ds.Tables["customers"];
            dt.Rows[0][1] = "Tran Thi A";
            da.Update(ds, "customers");

        }
    }
}
